<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>代理列表</title>
<link href="/majiang/Public/admin/css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/majiang/Public/admin/js/jquery.js"></script>
<script src="/majiang/Public/admin/js/jquery.min.js"></script>
<script src="/majiang/Public/layer/layer.js"></script>
<link href="/majiang/Public/admin/css/select.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/majiang/Public/admin/js/select-ui.min.js"></script>
<script type="text/javascript" src="/majiang/Public/My97DatePicker/WdatePicker.js"></script>
<script>
$(document).ready(function(e) {
    $("#level").uedSelect({
		width : 120			  
	});
});
</script>
</head>

<body>

	<div class="place">
		<span>位置：</span>
		<ul class="placeul">
			<li><a href="<?php echo U('index/welcome');?>">首页</a></li>
			<li><a href="<?php echo U('agency/agencyunder');?>">代理开发玩家</a></li>
		</ul>
    </div>
    
    <div class="formbody">
		<form name="seachform" id="seachform" action="<?php echo U('agency/agencyunder');?>" method="post">
			<ul class="seachform">
				<li><label>昵称</label><input name="info[nick_name]" id="nick_name" value="<?php echo ($nick_name); ?>" type="text" class="scinput" style="width: 100px;" /></li>
				<li><label>玩家ID</label><input name="info[tel]" id="tel" value="<?php echo ($tel); ?>" type="text" class="scinput" style="width: 100px;" /></li>
				<li><label>关注时间</label>
					<input name="info[starttime]" id="starttime" class="dfinput" type="text" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',maxDate:'#F{ $dp.$D(\'endtime\')||\'2100-10-01\' }'})" datatype="*" errormsg="时间范围开始值不能为空！" maxlength="20" style="width: 120px;" readonly value="<?php echo ($starttime); ?>" />-
					<input name="info[endtime]" id="endtime" class="dfinput" type="text" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',minDate:'#F{ $dp.$D(\'starttime\') }',maxDate:'2100-10-01'})" datatype="*" errormsg="时间范围结束值范围不能为空！" maxlength="20" style="width: 120px;" readonly value="<?php echo ($endtime); ?>" />
					<i class="Validform_checktip"></i></li>
				<li><label>代理级别</label>
					<div class="vocation">
						<select id="level" name="info[level]">
							<option value="">请选择级别</option>
							<?php if(is_array($getagentlevel1)): $i = 0; $__LIST__ = $getagentlevel1;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$data): $mod = ($i % 2 );++$i;?><option value="<?php echo ($key); ?>" <?php if($key == $level ): ?>selected<?php endif; ?>><?php echo ($data); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
						</select>
					</div>
				</li>
				<li><label>&nbsp;</label><input name="" type="submit" class="scbtn" value="查询"/></li>
			</ul>
		</form>
		
		<table class="tablelist">
			<thead>
				<tr>
				        <th>玩家ID</th>
						<th>昵称</th>
                        <th>推荐人</th>
					    <th>关注时间</th>
                        <th>在线状态</th>
						<th>级别</th>
                        <th>操作人</th>
						<th>佣金比例</th>
                        <th>账户余额</th>
                        <th>剩余天数</th>
						<th>操作</th>
				</tr>
			</thead>
			<?php if(is_array($listinfo)): $i = 0; $__LIST__ = $listinfo;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$admin): $mod = ($i % 2 );++$i;?><tr>
			    <td><?php echo ($admin["game_userid"]); ?></td>
				<td><?php echo ($admin["nickname"]); ?></td>
				<td><?php echo ($admin["referee_nickname"]); ?></td>
				<td><?php echo (date("Y-m-d H:i:s",$admin["addtime"])); ?></td>
				<td><?php echo ($online1[$admin['online']]); ?></td>
				<td><?php echo ($getagentlevel1[$admin['agentlevel']]); ?></td>
				<td><?php echo ($admin["admin_username"]); ?></td>
				<td><?php echo ($admin["moneyrate"]); ?></td>
				<td><?php echo ($admin["money"]); ?></td>
				<td><?php echo ($admin["gameendtime"]); ?></td>
				<td>
				  <?php if($admin["employee"] != 2): ?><a href="<?php echo U('agency/setemployee',array('user_id'=>$admin['user_id']));?>" onclick="{if(confirm('确认设为员工吗?')){return true;}return false;}" class="tablelink">设为员工</a>
						<?php else: ?>
						<font style="color:red;">员工</font><?php endif; ?>
					<a href="javascript:showlist(<?php echo ($admin["user_id"]); ?>);"><p>查看</p></a>
					<a style="color:black" href="<?php echo U('agency/del',array('user_id'=>$admin['user_id']));?>" onclick="{if(confirm('确认删除?')){return true;}return false;}" class="tablelink">删除</a>
					<a href='javascript:agencylevel(<?php echo ($admin['user_id']); ?>,"<?php echo ($admin["nickname"]); ?>",<?php echo ($admin['agentlevel']); ?>);' style="cursor:pointer;">设置等级</a>
				</td>
			</tr>
			<tbody id="list_<?php echo ($admin["user_id"]); ?>" style="display:none;">
				<?php if(is_array($admin["child"])): $i = 0; $__LIST__ = $admin["child"];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$child): $mod = ($i % 2 );++$i;?><tr>
				    <td>--<?php echo ($child["game_userid"]); ?></td>
					<td><?php echo ($child["nickname"]); ?></td>
					<td><?php echo ($child["referee_nickname"]); ?></td>
					<td><?php echo (date("Y-m-d H:i:s",$child["addtime"])); ?></td>
					<td><?php echo ($online1[$child['online']]); ?></td>
					<td><?php echo ($getagentlevel1[$child['agentlevel']]); ?></td>
					<td><?php echo ($child["admin_username"]); ?></td>
					<td><?php echo ($child["moneyrate"]); ?></td>
					<td><?php echo ($child["money"]); ?></td>
					<td><?php echo ($child["gameendtime"]); ?></td>
					<td>
					  <?php if($admin["employee"] != 2): ?><a href="<?php echo U('agency/setemployee',array('user_id'=>$admin['user_id']));?>" onclick="{if(confirm('确认设为员工吗?')){return true;}return false;}" class="tablelink">设为员工</a>
						<?php else: ?>
						<font style="color:red;">员工</font><?php endif; ?>
						<a href='javascript:parentIframe(<?php echo ($child['user_id']); ?>,"<?php echo ($child["nickname"]); ?>");' style="cursor:pointer;">查看</a>
						<a style="color:black" href="<?php echo U('agency/del',array('user_id'=>$admin['user_id']));?>" onclick="{if(confirm('确认删除?')){return true;}return false;}" class="tablelink">删除</a>
						<a href='javascript:agencylevel(<?php echo ($admin['user_id']); ?>,"<?php echo ($admin["nickname"]); ?>",<?php echo ($admin['agentlevel']); ?>);' style="cursor:pointer;">设置等级</a>
					</td>
				</tr><?php endforeach; endif; else: echo "" ;endif; ?>
			</tbody><?php endforeach; endif; else: echo "" ;endif; ?>
		</table>

		<?php echo ($pageshow); ?>

    </div>
	<script type="text/javascript">
		$('.tablelist tbody tr:odd').addClass('odd');
	</script>
	<script type="text/javascript">
	//查看隐藏的下级
	function showlist(user_id){
		$("#list_"+user_id).toggle();
	}

    //弹出一个iframe层
	function parentIframe(user_id,nickname){
		layer.open({
			type: 2,
			title: '下级玩家['+nickname+']',
			maxmin: true,
			shadeClose: true, //点击遮罩关闭层
			area : ['800px' , '520px'],
			content: "<?php echo U('agency/agencythird');?>&user_id="+user_id
		});
	}
	</script>
	<script type="text/javascript">
	$('.tablelist tbody tr:odd').addClass('odd');
	 //设置等级弾层
	function agencylevel(user_id,nickname,level){
		
        layer.open({
            type: 2,
            title: '设置['+'代理:'+nickname+']等级',
            maxmin: true,
            shadeClose: true, //点击遮罩关闭层
            area : ['800px' , '520px'],
            content: "<?php echo U('agency/set_agencylevel');?>&user_id="+user_id+"&agentlevel="+level
        });
    }
</script>
</body>
</html>